package com.lmk.mkcc.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.lmk.mkcc.domain.UserRegister;
import com.lmk.mkcc.mapper.UserRegisterMapper;
import com.lmk.mkcc.service.IUserRegisterService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kun
 * @since 2022-10-01
 */
@Service
public class UserRegisterServiceImpl extends ServiceImpl<UserRegisterMapper, UserRegister> implements IUserRegisterService {


    @Override
    public UserRegister getUserIdByCode(String registerCode) {
        EntityWrapper<UserRegister> wrapper = new EntityWrapper<>();
        wrapper.eq("code",registerCode);
        return selectOne(wrapper);
    }

    @Override
    public void save(String complexRandomString, Long id) {
        UserRegister register = new UserRegister();
        register.setCode(complexRandomString);
        register.setUserId(id);
        insert(register);
    }

    @Override
    public UserRegister selectByUserId(Long id) {
        EntityWrapper<UserRegister> wrapper = new EntityWrapper<>();
        wrapper.eq("user_id",id);
        return selectOne(wrapper);
    }
}
